import * as THREE from "../lib/three.module.js";
import { OrbitControls } from "../lib/controls/OrbitControls.js";

const webGLControls = function () {
  this.renderer = new THREE.WebGLRenderer({ antialias: true });
  this.renderer.setPixelRatio(window.devicePixelRatio);
  this.renderer.setSize(window.innerWidth, window.innerHeight);
  this.renderer.outputEncoding = THREE.sRGBEncoding;
  // 阴影
  this.renderer.shadowMap.enabled = true;
  // 阴影 -- 清晰
  this.renderer.shadowMap.type = THREE.PCFSoftShadowMap;
  this.container.appendChild(this.renderer.domElement);

  this.controls = new OrbitControls(this.camera, this.renderer.domElement);
  // target为相机运动时，所注视的坐标
  // this.controls.target.set(0, 100, 0);
  // 相机平移
  this.controls.enablePan = false;
  this.controls.update();
  // 相机旋转时开启阻尼
  this.controls.enableDamping = true;
  // 阻尼系数
  // this.controls.dampingFactor = 1;
  this.controls.autoRotate = true;
};

export default webGLControls;
